<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">

	<title></title>  <link rel="icon" href="/template/pc1/images/wmh_favicon.ico" type="image/x-icon" />
	<meta name="keywords" content="">
	<meta name="description" content="">

	<link rel="shortcut icon" href="/template/pc1/images/wmh_favicon.ico">
	<link href="${base}/res/plugins/hplus/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
	<link href="${base}/res/plugins/hplus/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
	<link href="${base}/res/plugins/hplus/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
	<link href="${base}/res/plugins/hplus/css/animate.css" rel="stylesheet">
	<link href="${base}/res/plugins/hplus/css/style.css?v=4.1.0" rel="stylesheet">
	<link href="${base}/res/plugins/hplus/css/plugins/toastr/toastr.min.css" rel="stylesheet">
    <link href="${base}/res/css/common.css" rel="stylesheet" type="text/css" />

</head>

<body class="white-bg">
<div class="path">
    积分兑换 &raquo; 订单列表
</div>
<div class="wrapper wrapper-content">
	<div class="row">
		<div class="col-sm-12" >
			<div class="alert alert-warning alert-dismissable">
				<button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
				可以对订单列表进行管理
			</div>
			<table id="cpTableEvents" data-toggle="table" data-mobile-responsive="true">
				<thead>
				<tr>
                    <th data-field="number" data-formatter="numberFormatter">序号</th>
					<th data-field="productName">商品名称</th>
					<th data-field="salesXin">消耗爱心</th>
					<th data-field="createDate">下单时间</th>
					<th data-field="name">姓名</th>
                    <th data-field="phone">电话</th>
                    <th data-field="allAddress">发货地址</th>
					<th data-field="orderStatus" data-formatter="opFormatter">订单状态</th>
				</tr>
				</thead>
			</table>
		</div>
	</div>
</div>
<script src="${base}/res/plugins/hplus/js/jquery.min.js?v=2.1.4"></script>
<script src="${base}/res/plugins/hplus/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${base}/res/plugins/hplus/js/content.js?v=1.0.0"></script>
<script src="${base}/res/plugins/hplus/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="${base}/res/plugins/hplus/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="${base}/res/plugins/hplus/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="${base}https://static.9hive.cn/global/vendor/layer/layer.js"></script>
<script src="${base}/res/plugins/hplus/js/plugins/toastr/toastr.min.js"></script>

<script>

	function numberFormatter(value, row, index){
		return index+1;
	}

    function opFormatter(value, row, index){
		var html='';
		if(row.orderStatus==0){
            html = '<a href="javascript:void(0)">[待发货]</a>';
			html+='<a href="javascript:void(0)" onclick="reship(\''+row.id+'\');" style="margin-left: 10px;color: red">[点击发货]</a>';
		}else if(row.orderStatus==1){
            html = '<a href="javascript:void(0)" onclick="edit(\''+row.id+'\');" >[待收货]</a>';
            html+='<a href="javascript:void(0)" onclick="sureReceipt(\''+row.id+'\');" style="margin-left: 10px;color: red">[确认收货]</a>';
		}else{
            html = '<a href="javascript:void(0)">[已收货]</a>';
		}
		return html;
	}

    // 确认发货
    function reship(ids) {
        layer.confirm('您确定要发货吗？', {
            btn: ['是','否'] //按钮
        }, function(){
            $.ajax({
                method:"post",
                url: '${base}/shop/integralOrders/reship',
                data:"id=" + ids + "",
                dataType: "json",
                success: function(data) {
                    if (data.code == 0) {
                        location.href='${base}/shop/integralOrders/list';
                    }
                }
            });
        });
    }

    // 确认收货
    function sureReceipt(ids) {
        layer.confirm('是否已经电话确认用户已经收货？', {
            btn: ['是','否'] //按钮
        }, function(){
            $.ajax({
                method:"post",
                url: '${base}/shop/integralOrders/sureReceipt',
                data:"id=" + ids + "",
                dataType: "json",
                success: function(data) {
                    if (data.code == 0) {
                        location.href='${base}/shop/integralOrders/list';
                    }
                }
            });
        });
    }

	function del(v) {
        $.post('delete',{"ids":v},function (e) {
			if(e.status == 'error'){
                toastr.error(e.message, '提示')
			}else{
                toastr.success('删除成功', '提示');
                $('#cpTableEvents').bootstrapTable('refresh');
			}
        })
    }
	function edit(v) {
		location.href = "edit?id="+v;
    }

    (function() {
        $('#cpTableEvents').bootstrapTable({
            url: "${base}/shop/integralOrders/ajaxlist",
            search: true,
            pagination: true,
            showRefresh: true,
            showToggle: true,
            showColumns: true,
            iconSize: 'outline',
            toolbar: '#eventsToolbar',
            icons: {
                refresh: 'glyphicon-repeat',
                toggle: 'glyphicon-list-alt',
                columns: 'glyphicon-list'
            }
        });

        $('#eventsToolbar').on('click',function (e) {
			location.href = 'add';
        })

		toastr.options = {
			"positionClass" : "toast-top-center"
		};

        if('${type!}' == 'save')
            toastr.success('添加成功', '提示')
		if('${type!}' == 'del')
            toastr.success('删除成功', '提示')
    })();
</script>
</body>

</html>
